import os
from PIL import Image
import cv2

png_path = 'E:\\STM32CUBEProjects\\103_st7735\\img\\32bit_24bit'
save_path = 'E:\\STM32CUBEProjects\\103_st7735\\img\\32bit_24bit\\ok\\'
#建立文件夹
# if not os._exists(save_path):
#     print('No_save_path file, making it...')
#     os.makedirs(save_path)
# else:
#     print('save_path has existed')
#遍历将图像中的位数32bit-->24bit
for image_name in sorted(os.listdir(png_path)):
    image_path = os.path.join(png_path,image_name)
    # img = Image.open(image_path)
    print('image_name:',image_name)
    img_24bit = cv2.imread(image_path)
    cv2.imwrite(save_path+image_name,img_24bit)
print('convert_finished')
